package com.hundsun.s3.platform.backstage.service.Impl;

import com.hundsun.s3.common.dto.Staff;
import com.hundsun.s3.common.util.BaseDao;
import com.hundsun.s3.platform.backstage.common.util.ChartUtils;
import com.hundsun.s3.platform.service.StaffManageService;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * com.hundsun.s3.platform.backstage.service.Impl
 *
 * @Description:
 * @Author: yangjun23614
 * @Date: Created in 15:39 2018/3/12
 * V1.0 15:39 2018/3/12
 */
@Service
public class StaffManageServiceImpl extends BaseDao implements StaffManageService{

    /**
     * @Description: 查询
     * @param:
     * @return:
     * @Author: yangjun23614
     * @Date: 11:18 2018/3/13
     * V1.0
     */
    @Override
    public List<Staff> qryStaffByParams(Map<String, Object> params, String functionId) {
        List<Staff> list = this.qry(functionId,params, Staff.class);
        return list;
    }

    /**
     * @Description: 总数
     * @param:
     * @return:
     * @Author: yangjun23614
     * @Date: 11:19 2018/3/13
     * V1.0
     */
    @Override
    public int qryStaffCountByParams(Map<String, Object> params, String functionId) {
        int[] count = new int[1];
        List<Map<String, String>> list = this.call(functionId,params);
        ChartUtils.getValuesInListMap(list,count);
        return count[0];
    }

    /**
     * @Description: 增加
     * @param:
     * @return:
     * @Author: yangjun23614
     * @Date: 11:19 2018/3/13
     * V1.0
     */
    @Override
    public String addStaff(Map<String, Object> params, String functionId) {
        String result = this.exc(functionId,params);
        if("执行成功".equals(result)) {
            return "1";
        }else {
            return result;
        }
    }

    /**
     * @Description:  判断存在
     * @param:
     * @return:
     * @Author: yangjun23614
     * @Date: 11:19 2018/3/13
     * V1.0
     */
    @Override
    public String judgeByParams(Map<String, Object> params, String functionId) {
        List<Map<String, String>> list = this.call(functionId,params);
        return list.get(0).get("is_exist");
    }

    /**
     * @Description: 更改状态码
     * @param:
     * @return:
     * @Author: yangjun23614
     * @Date: 15:49 2018/3/13
     * V1.0
     */
    @Override
    public String modifyState(Map<String, Object> params, String functionId) {
        String result = this.exc(functionId,params);
        if("执行成功".equals(result)) {
            return "1";
        }else {
            return result;
        }
    }

    /**
     * @Description: 修改信息
     * @param:
     * @return:
     * @Author: yangjun23614
     * @Date: 15:49 2018/3/13
     * V1.0
     */
    @Override
    public String modifyStaff(Map<String, Object> params, String functionId) {
        String result = this.exc(functionId,params);
        if("执行成功".equals(result)) {
            return "1";
        }else {
            return result;
        }
    }

}
